# coding=utf-8
import enum
import json


class LoginCode(enum.Enum):
    SUCCESS = 200
    NOT_MATCH = 401
    IS_BAN = 402
    IN_OTHER = 403
    IS_DELETE = 404
    WAIT = 405
    ERROR = 500


def login_result(code, data={}):
    login_success = {"code": LoginCode.SUCCESS.value, "msg": '登录成功', "data": {}}
    login_not_match = {"code": LoginCode.NOT_MATCH.value, "msg": '用户名或密码错误', "data": {}}
    login_is_ban = {"code": LoginCode.IS_BAN.value, "msg": '账号被封', "data": {}}
    login_in_other = {"code": LoginCode.IN_OTHER.value, "msg": '账号在其他地方登录', "data": {}}
    login_is_delete = {"code": LoginCode.IS_BAN.value, "msg": '账号已经注销', "data": {}}
    login_wait = {"code": LoginCode.WAIT.value, "msg": "当前服务器人数已满", "data": {}}
    login_error = {"code": LoginCode.ERROR.value, "msg": '登录失败', "data": {}}
    login_dict = {
        LoginCode.SUCCESS: login_success,
        LoginCode.NOT_MATCH: login_not_match,
        LoginCode.IS_BAN: login_is_ban,
        LoginCode.IN_OTHER: login_in_other,
        LoginCode.IS_DELETE: login_is_delete,
        LoginCode.WAIT: login_wait,
        LoginCode.ERROR: login_error
    }
    result = login_dict[code]
    result["data"] = json.dumps(data, ensure_ascii=False)
    return result


class AllInfoCode(enum.Enum):
    SUCCESS = 200
    ERROR = 500


def all_info_result(code, data={}):
    all_info_success = {"code": AllInfoCode.SUCCESS.value, "msg": '加载成功', "data": {}}
    all_info_error = {"code": AllInfoCode.ERROR.value, "msg": '加载失败', "data": {}}
    all_info_dict = {
        AllInfoCode.SUCCESS: all_info_success,
        AllInfoCode.ERROR: all_info_error
    }
    result = all_info_dict[code]
    result["data"] = json.dumps(data, ensure_ascii=False)
    return result
